-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MLX Cleanup #187
MLX Cleanup #187
Conversation
- updated readme - updated makefile
xcodebuild clean build-for-testing -scheme ${{ matrix.run-config['scheme'] }} -destination '${{ matrix.run-config['clean-destination'] }}' -skipPackagePluginValidation | xcpretty | ||
xcodebuild test -only-testing WhisperKitTests/UnitTests -scheme ${{ matrix.run-config['scheme'] }} -destination '${{ matrix.run-config['test-destination'] }}' -skipPackagePluginValidation | ||
xcodebuild clean build-for-testing test \ | ||
${{ matrix.run-config['test-cases'] }} \ | ||
-scheme ${{ matrix.run-config['scheme'] }} \ | ||
-destination '${{ matrix.run-config['test-destination'] }}' \ | ||
-skipPackagePluginValidation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is merged into single command xcodebuild clean build-for-testing test
@xcodebuild CLANG_ENABLE_CODE_COVERAGE=NO VALID_ARCHS=arm64 clean build \ | ||
-configuration Release \ | ||
-scheme whisperkit-Package \ | ||
-destination generic/platform=macOS \ | ||
-derivedDataPath .build/.xcodebuild/ \ | ||
-clonedSourcePackagesDirPath .build/ \ | ||
-skipPackagePluginValidation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have to use xcodebuild
because of mlx
@swift build -c release --product whisperkit-cli | ||
@xcodebuild CLANG_ENABLE_CODE_COVERAGE=NO VALID_ARCHS=arm64 clean build \ | ||
-configuration Release \ | ||
-scheme whisperkit-cli \ | ||
-destination generic/platform=macOS \ | ||
-derivedDataPath .build/.xcodebuild/ \ | ||
-clonedSourcePackagesDirPath .build/ \ | ||
-skipPackagePluginValidation | ||
|
||
|
||
test: | ||
@echo "Running tests..." | ||
@swift test -v | ||
@xcodebuild clean build-for-testing test \ | ||
-scheme whisperkit-Package \ | ||
-only-testing WhisperKitMLXTests/MLXUnitTests \ | ||
-only-testing WhisperKitTests/UnitTests \ | ||
-destination 'platform=macOS,arch=arm64' \ | ||
-skipPackagePluginValidation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have to use xcodebuild
because of mlx
Package.swift
Outdated
.package(url: "https://github.com/ml-explore/mlx-swift", branch: "main"), | ||
.package(url: "https://github.com/ml-explore/mlx-swift", revision: "d6d9472da5bf7ec2654e8914bd1d15622f45b6a9"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the latest version of mlx
0.16.0 breaks the implementation, let's pin it to the last commit before the breaking one, I'll have to talk to mlx
team about the issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, solution provided here ml-explore/mlx-swift#117
README.md
Outdated
Task { | ||
let pipe = try? await WhisperKit() | ||
let transcription = try? await pipe!.transcribe(audioPath: "path/to/your/audio.{wav,mp3,m4a,flac}")?.text | ||
print(transcription) | ||
} | ||
let pipe = try await WhisperKit() | ||
// Transcribe the audio file | ||
let transcription = try await pipe.transcribe(audioPath: "path/to/your/audio.{wav,mp3,m4a,flac}")?.text | ||
// Print the transcription | ||
print(transcription) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed not needed Task
, decided to remove ?
from try ?
. When the potential user does copy paste from the readme I think it's better when the error is not ignored
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great, in the final stages of completing the MLX support project 🎉. Left a few comments and questions here to consider.
``` | ||
|
||
### Model Selection | ||
|
||
WhisperKit automatically downloads the recommended model for the device if not specified. You can also select a specific model by passing in the model name: | ||
You have to specify the model by passing the model name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now user has to pass either model
and / or mlxModel
, depending whether mlx is used or not
public func prewarmModels() async throws { | ||
try await loadModels(prewarmMode: true) | ||
} | ||
|
||
public func loadModels( | ||
prewarmMode: Bool = false | ||
) async throws { | ||
modelState = prewarmMode ? .prewarming : .loading | ||
assert(modelFolder != nil || mlxModelFolder != nil, "Please specify `modelFolder` or `mlxModelFolder`") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this crash on prod builds? If so it should throw instead of crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not going to crash on a prod build
@@ -211,114 +228,80 @@ open class WhisperKit { | |||
} | |||
} | |||
|
|||
/// Sets up the model folder either from a local path or by downloading from a repository. | |||
public func setupModels( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this deleted for a specific reason? Would be preferred to keep with with some adjustments since it was previously a public function and may be getting called elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously setupModels
would set modelFolder
property. Right now we have to set either modelFolder
or / and mlxModelFolder
depending on the pipeline setup. In this context this function doesn't make sense any more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved pending the setupModels change (also to run the tests)
Test passing ✅ |
In this PR:
added new params to
WhisperKit
:mlxModel
if specified, it will be used to specify which mlx model to downloadmlxModelRepo
if specified, it will be used to specify the repo where the mlx model is storedmlxModelFolder
if specified, it will point to the local folder where the mlx model is storedadded new options to
CLIArguments
:mlxModel
,mlxModelPath
see the explanation abovefeatureExtractorType
,audioEncoderType
,textDecoderType
to specify which type (coreml or or mlx) should be used for given pipeline stepupdated readme to reflect the changes above
updated makefile to reflect the changes above
simplified CI unit test
To do:
xcodebuild
instead ofswift build